#include <iostream>
using namespace std;

template <typename T>
class Sample
{
public:
    Sample(T arr[], int size)
    {
        this->size = size;
        for (int i = 0; i < size; i++)
        {
            this->arr[i] = arr[i];
        }
    }
    void show()
    {
        for (int i = 0; i < size; i++)
        {
            cout << arr[i] << " ";
        }
    }
    void updateArr(T arr[])
    {
        for (int i = 0; i < size; i++)
        {
            arr[i] = this->arr[i];
        }
    }
    void insertSort();
    void bubbleSort();
private:
    T arr[10];
    int size;
};

template <typename T>
void Sample<T>::insertSort()
{
    for (int i = 1; i < size; i++)
    {
        for (int j = i; j > 0; j--)
        {
            if (arr[j] < arr[j - 1])
            {
                T temp = arr[j];
                arr[j] = arr[j - 1];
                arr[j - 1] = temp;
            }
        }
    }
}

template <typename T>
void Sample<T>::bubbleSort()
{
    for (int i = 0; i < size; i++)
    {
        int flag = 0;
        for (int j = 0; j < size - i - 1; j++)
        {
            if (arr[j] > arr[j + 1])
            {
                T temp = arr[j];
                arr[j] = arr[j + 1];
                arr[j + 1] = temp;
                flag = 1;
            }
        }
        if (flag == 0)
        {
            break;
        }
    }
}



int main()
{
    int arr[] = {1, 5, 3, 4, 2, 8, 6, 7, 51, 101};
    int size = sizeof(arr) / sizeof(arr[0]);
    Sample<int> s(arr, size);
    // s.insertSort();
    s.bubbleSort();
    s.updateArr(arr);
    for (int i = 0; i < size; i++)
    {
        cout << arr[i] << " ";
    }

    return 0;
}